package com.cg.design.graphicdesignpattern.decorator;

import org.junit.Test;

/**
 * Decorator装饰模式测试类
 *
 * @program: LeetCode->DecoratorTest
 * @description: Decorator装饰模式测试类
 * @author: cg
 * @create: 2022-03-25 19:23
 **/
public class DecoratorTest {

    @Test
    public void testDecorator() {
        Display d1 = new StringDisplay("Hello, world.");
        Display d2 = new SideBorder(d1, '#');
        Display d3 = new FullBorder(d2);
        d1.show();
        d2.show();
        d3.show();
        Display d4 = new SideBorder(
                new FullBorder(
                        new FullBorder(
                                new SideBorder(
                                        new FullBorder(
                                                new StringDisplay("你好，广儿。")
                                        ),
                                        '*'
                                )
                        )
                ),
                '/'
        );
        d4.show();
        Display d5 = new FullBorder(
                new UpDownBorder(
                        new SideBorder(
                                new UpDownBorder(
                                        new SideBorder(
                                                new StringDisplay("你好，广儿。"),
                                                '*'
                                        ),
                                        '='
                                ),
                                '|'
                        ),
                        '/'
                )
        );
        d5.show();
        MultiStringDisplay d6 = new MultiStringDisplay();
        d6.add("早上好。");
        d6.add("下午好。");
        d6.add("晚安，明天见。");
        d6.show();
        Display d7 = new FullBorder(d6);
        d7.show();
    }

}
